﻿using Logistics.Utility;
using System.Net;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace Logistics.WebApi.Filters
{
    public class IPFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if (!DBConfig.RquestAccess(actionContext.Request))
            {
                actionContext.Response = new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    Content = new StringContent("警告！非法请求！")
                };
                return;
            }
            base.OnActionExecuting(actionContext);
        }
    }
}